#ifndef SERIALSERVER_H
#define SERIALSERVER_H

#include <QObject>
#include <QSerialPort>
#include <QWaitCondition>
#include <QMutex>
#include <QCoreApplication>
#include <QDebug>
#include <QThread>

class SerialServer : public QObject
{
    Q_OBJECT
public:
    SerialServer();
    ~SerialServer();

    // 打开串口
    bool openSerialPort(const QString &portName, unsigned int baudRate, unsigned char dataBits = 8, unsigned char parity = 0, unsigned char stopBits = 1);
    void closeSerialPort();         // 关闭串口
    bool isSerialPortOpen() const;  // 串口是否打开

public slots:
    void ReceviceSerialData();                          // 接收串口数据
    void SendSerialData(const QByteArray &data);        // 发送串口数据

signals:
    void serialDataReceivedReady(const QByteArray &data);
    void serialDataSendReady(const QByteArray &data);


private:
    QSerialPort *m_serial;
    QByteArray m_DataBuf;



};

#endif // SERIALSERVER_H
